package com.shell.governor.user.rx;

import com.shell.bee.base.utils.StringUtil;
import com.shell.bee.file.utils.FileHelper;
import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.shell.governor.user.UserEvent;
import com.shell.governor.user.po.PubUser;
import com.shell.governor.user.po.PubUserExtra;
import com.shell.governor.user.vo.PubUserVo;
import org.springframework.stereotype.Component;

@Component
public class SetFilesSubscriber extends OnErrorNotImplementedSubscriber<UserEvent> {
	public void onApplicationEvent(UserEvent event) {
		PubUserVo userVo = event.getUserVo();
		PubUser user = event.getUser();
		PubUserExtra userExtra = event.getUserExtra();
		if (StringUtil.notEmpty(userVo.getCertFileIds())) {
			FileHelper.setRelateId(userVo.getCertFileIds(), user.getUserId(), "2");
		}
		if (StringUtil.notEmpty(userVo.getAuthFileIds())) {
			FileHelper.setRelateId(userVo.getAuthFileIds(), userExtra.getAuthFileRlatId(), "9");
		}
	}
}
